(function () {
    var core = ecui,
        util = core.util,
        ui = ecui.ui,
        dom = ecui.dom;

    ecui.util.extend(NS.data, {
        routes: ['', '#/approval/detail.order', '#/approval/detail.contract', '#/approval/detail.play', '#/approval/detail.sponsor', '#/approval/detail.musician'],
        messageType: [[], ['订场', '预定场', '定场', '巡演'], ['合同', '包场合同', '分票合同', '商务合同', '自办合同'], ['演出'], ['主办方'], ['音乐人']]
    });
    ecui.util.extend(NS.ui, {
        MessageItem: ecui.inherits(
            ui.Control,
            function (el, options) {
                ui.Control.call(this, el, options);
                this.messageId = options.messageId;
            },
            {
                onclick: function () {
                    ecui.esr.request(
                        'readdata@GET /erp-management/message/read/' + this.messageId,
                        function () {
                            var data = ecui.esr.getData('readdata');
                            if (data instanceof Object) {
                                dom.addClass(dom.parent(this.getMain()), 'read');
                            }
                        }.bind(this),
                        function () {
                            var data = ecui.esr.getData('readdata');
                            if (data instanceof Object) {
                                dom.addClass(dom.parent(this.getMain()), 'read');
                            }
                        }.bind(this)
                    );
                }
            }
        )
    });
    ecui.esr.addRoute('message', {
        model: [
            // 'messages@POST /erp-management/message/list'
        ],
        weight: 1,
        main: 'nav_tab_message',
        view: 'home.message',
        frame: true,
        queryUrl: '@FORM /erp-management/message/list?messageSearchForm',
        onbeforerequest: function (context) {
        },
        onbeforerender: function (context) {
        },
        onafterrender: function (context) {
            ecui.dispatchEvent(ecui.get('message-list-view'), 'refresh');
        }
    });
}());